package com.jang.mapper.cases;

import com.jang.Entity.cases.CaseRuningEntity;
import com.jang.Entity.cases.ConfigEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Controller;

import java.util.List;

@Mapper
@Controller
public interface CaseRuningMapper {
    @Select("select * from apicase where case_id=#{case_id} and delete_flag =0")
    CaseRuningEntity getApiCaseById(@Param("case_id") String case_id);

    @Select("select * from case_pre_relation where case_id=#{case_id} and delete_flag =0")
    List<ConfigEntity> getPreApiById(@Param("case_id") String case_id);

    @Select("select a.* from headerconfig a,case_header_relation b where b.case_id=#{case_id},b.header_id=a.header_id and a.delete_flag =0")
    List<ConfigEntity> findHeaderByCaseId(@Param("case_id")String case_id);

    @Select("<script>"+"select * from apicase"
            + " where project_id=#{project_id}"
            +"<if test='name!=null' >"
            +"name=#{name}"
            +"</if>"
            + "</script>")
    List<CaseRuningEntity> findCaseEntityList(CaseRuningEntity caseRuningEntity);
}
